﻿<%@ Page Title="" Language="C#" MasterPageFile="~/EasyUI.Master" AutoEventWireup="true" CodeBehind="plantlist.aspx.cs" Inherits="jnxc.Web.preventionmethod.plantlist" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
     <style>
        html, body {
            height:100%
        } 
    </style>
    <script type="text/javascript">     
        $.extend($.fn.tree.methods, {
            getLevel: function (jq, target) {
                var l = $(target).parentsUntil("ul.tree", "ul");
                return l.length + 1;
            }
        });
        $(function () {
            InitTree();
            InitGird();
            
            });
        //初始化表格
        function InitGird() {
            $('#tt').datagrid({
                title: '防治方法列表', //表格标题
                url: 'GetPreMethod.ashx', //请求数据的页面
                sortName: 'pname', //排序字段
                idField: 'pid', //标识字段,主键
                iconCls: '', //标题左边的图标
                width: '100%', //宽度
                //height: $(parent.document).find("#mainPanle").height() - 35 > 0 ? $(parent.document).find("#mainPanle").height() - 35 : 500, //高度
                nowrap: false, //是否换行，True 就会把数据显示在一行里
                striped: true, //True 奇偶行使用不同背景色
                collapsible: false, //可折叠
                sortOrder: 'desc', //排序类型
                remoteSort: true, //定义是否从服务器给数据排序
                fitColumns: true,
                method: 'post',
                columns: [[                    
	                { title: '植物名称', field: 'pname', width: 150, sortable: true },
                    { title: '有害生物名称', field: 'hname', width: 150, sortable: true },
                    { title: '防治类型', field: 'cname', width: 150, sortable: true },
                    {
                        title: '详细', field: 'psid', width: 80, formatter: function (value, row, index) {
                            return '<a style="color:red" href="javascript:" onclick="$(this).parent().click();showData(' + value + ');return false;">详细信息</a>';
                        }
                    }
                ]],                
                queryParams: { "action": "queryplant" },
                pagination: true, //是否开启分页
                pageNumber: 1, //默认索引页
                pageSize: 20, //默认一页数据条数
                rownumbers: true, //行号
                singleSelect: true
            });
        }       
        function InitTree() {
            $('#pt').tree({
                url: '../plantinfo/GetPlant.ashx', //请求数据的页面               
                width: '100%', //宽度                
                lines: true,
                method: 'post',
                queryParams: { "action": "queryr" },               
                onClick: function (node) {
                    if (node.text != "") {
                        $('#ids').val(node.id);
                        reloadgrid();
                    }
                }
            });          
        }
        function getQueryParams(queryParams) {
            var ids = $("#ids").val();            
            queryParams.ids = ids;            
            return queryParams;

        }
        //增加查询参数，重新加载表格  
        function reloadgrid() {

            //查询参数直接添加在queryParams中      
            var queryParams = $('#tt').datagrid('options').queryParams;
            getQueryParams(queryParams);
            $('#tt').datagrid('options').queryParams = queryParams;
            $("#tt").datagrid('reload');

        }
        function showData(value,row) {

            var row = $('#tt').datagrid('getSelected');
            if (row == null) {
                $.messager.alert("提示", "请选择要修改的行！", "info");
            }
            if (row) {
                
                $("#hname").text(row.hname);
                $("#cname").text(row.cname);
                $("#pname").text(row.pname);
                if (row.psid) {
                    var result = $.ajax({
                        url: "../preventionskill/GetPreSkill.ashx?action=getinfo&pid=" + row.psid,
                        type: 'post',
                        dataType: 'json',
                        async: false,
                        cache: false
                    }).responseText;
                    $("#psinfo").html(result);
                }
                $('#dlg').dialog('open').dialog('setTitle', '详细信息');
               
            }
        }

    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div class="easyui-layout" style="width:100%; height:100%;" id="mycon">
        <div region="west" split="true" title="植物检索" style="width: 180px;overflow:scroll" id="west">
            <ul id="pt"></ul>
            
        </div>
        <div region="center" style="background: #eee; overflow-y: hidden">
            <table id="tt">
            </table>
        </div>
        <div id="dlg" class="easyui-dialog" style="width: 600px; height:350px; padding: 10px 20px;overflow:auto;"
            data-options="closed:true,maximizable:true,resizable:true,buttons:'#dlg-buttons',shadow:false">

            <form id="fm" method="post">
                 <input name="ids" id="ids" type="hidden" />  
                <div class="fitem">
                    <label>植物名：</label>
                    <span id="pname" ></span>
                </div>
                <div class="fitem">
                    <label>有害生物名：</label>
                    <span id="hname" > </span>                   
                </div>
                <div class="fitem">
                    <label>防治方法：</label>
                    <span id="cname" ></span>
                </div>
                <div>
                    <label>有害生物详细情况：</label>                    
                </div>  
                <div id="psinfo" />             
            </form>
        </div>
        <div id="dlg-buttons">            
            <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-cancel'" onclick="javascript:$('#dlg').dialog('close')">关闭</a>
        </div>
    </div>
</asp:Content>
